package top.zhangjianyong.entity;

import java.lang.reflect.Field;

public interface CanSetGetField {
    default String getField(String name) throws NoSuchFieldException, IllegalAccessException {
        Field field = this.getClass().getDeclaredField(name);
        field.setAccessible(true);
        return (String) field.get(this);
    }

    default void setField(String name, Object value) throws NoSuchFieldException, IllegalAccessException {
        Field field = this.getClass().getDeclaredField(name);
        field.setAccessible(true);
        field.set(this, value);
    }
}
